with Ada.Calendar.Time_Zones;
package body v8.Class_Date is
   use type Ada.Calendar.Time, double;

   ada_start : Ada.Calendar.Time := Ada.Calendar.Time_Of (1901, 1, 1);
   js_start : Ada.Calendar.Time := Ada.Calendar.Time_Of(1970, 1, 1);
   time_zone : double := double(Ada.Calendar.Time_Zones.UTC_Time_Offset) * 60.0;

   ------------
   -- To_Ada --
   ------------

   function To_Ada (this : Date) return Ada.Calendar.Time is
   begin
      return js_start + Duration(this.Number_Value / 1000.0 + time_zone);
   end To_Ada;

   -----------
   -- To_JS --
   -----------

   function To_JS (time : Ada.Calendar.Time) return Pointer is
   begin
      return Create((double(time - js_start) - time_zone)* 1000.0);
   end To_JS;

end v8.Class_Date;
